package com.mz.ozy.mvp.presenter;

import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.mvp.model.TrainCommentModel;
import com.mz.ozy.mvp.view.TrainCommentContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class TrainCommentPresenter extends BasePresenterImpl<TrainCommentContract.View> implements TrainCommentContract.Presenter {

    private TrainCommentModel mTrainCommentModel;

    public TrainCommentPresenter() {
        mTrainCommentModel = new TrainCommentModel();
    }

    @Override
    public void queryCommentList(Context context, String cid, String type, int pageNo) {
        mTrainCommentModel.queryCommentList(context, cid,type, pageNo)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {

                    @Override
                    public void onSuccesss(JSONObject jsonObject) {
                        mView.getCommentList(jsonObject);
                    }
                });
    }
}
